#!/usr/bin/perl -w

BEGIN {
	push @::INC,"../lib";
}

use strict;
$::DEBUG=0;
use C_server2;

if(!exists($::ENV{TRUECL_ETC})) {
	die("Missing environment variable TRUECL_ETC.");
}

$::request=undef; $::err=undef;
$::server=new C_server2(PKI => 1, PORT => 44553);
if(!defined($::server)) {
	print "Error defining server: ",C_server2->error,"\n";
	exit 1;
}

# $::server->add_key("stbe905a","testkey");
$::server->set_params(WINDOW => 255);
while(1) {
	($::request,$::err)=$::server->accept;

	if($::err) {
		print "Error: $::err\n";
		next;
	}
	if(!defined($::request)) {
		print "Error: ",C_server2->error,"\n";
	}
	($::res,$::err)=$::server->send_response("Response for $::request");
	if(!defined($::res)) {
		print "Error: Unable to send response: $::err\n";
	} 
}
$::server=undef;

1;

